import { customSystemConfig } from "@/config/customSystemConfig";
import { MetaclassType } from "@/constants/MetaclassType";
import type { PropertyDropdownOption } from "../../types";

export type ValueSpecificationType = {
  value: MetaclassType;
  label: string;
  icon: string;
  default: string | number | null | boolean;
};
export const valueSpecificationTypes: ValueSpecificationType[] = [
  {
    value: MetaclassType.ElementValue,
    label: "元素值",
    icon: "statics/images/sysml/ElementValue.svg",
    default: null
  },
  {
    value: MetaclassType.StringExpression,
    label: "表达式",
    icon: "statics/images/sysml/StringExpression.svg",
    default: ""
  },
  {
    value: MetaclassType.InstanceValue,
    label: "实例值",
    icon: "statics/images/sysml/InstanceValue.svg",
    default: null
  },
  {
    value: MetaclassType.LiteralBoolean,
    label: "布尔值",
    icon: "statics/images/sysml/LiteralBoolean.svg",
    default: false
  },
  {
    value: MetaclassType.LiteralInteger,
    label: "整数",
    icon: "statics/images/sysml/LiteralInteger.svg",
    default: 0
  },
  {
    value: MetaclassType.LiteralNull,
    label: "Null",
    icon: "statics/images/sysml/LiteralNull.svg",
    default: null
  },
  {
    value: MetaclassType.LiteralReal,
    label: "实数",
    icon: "statics/images/sysml/LiteralReal.svg",
    default: 0
  },
  {
    value: MetaclassType.LiteralString,
    label: "字符串",
    icon: "statics/images/sysml/LiteralString.svg",
    default: ""
  },
  {
    value: MetaclassType.LiteralUnlimitedNatural,
    label: "无限自然数",
    icon: "statics/images/sysml/LiteralUnlimitedNatural.svg",
    default: 0
  },
  {
    value: MetaclassType.OpaqueExpression,
    label: "不透明表达式",
    icon: "statics/images/sysml/OpaqueExpression.svg",
    default: ""
  }
];

export const instanceValueSpecificationTypes: ValueSpecificationType[] = [
  {
    value: MetaclassType.LiteralBoolean,
    label: "布尔值",
    icon: "statics/images/sysml/LiteralBoolean.svg",
    default: false
  },
  {
    value: MetaclassType.LiteralInteger,
    label: "整数",
    icon: "statics/images/sysml/LiteralInteger.svg",
    default: 0
  },
  {
    value: MetaclassType.LiteralReal,
    label: "实数",
    icon: "statics/images/sysml/LiteralReal.svg",
    default: 0
  },
  {
    value: MetaclassType.LiteralString,
    label: "字符串",
    icon: "statics/images/sysml/LiteralString.svg",
    default: ""
  },
  {
    value: MetaclassType.LiteralUnlimitedNatural,
    label: "无限自然数",
    icon: "statics/images/sysml/LiteralUnlimitedNatural.svg",
    default: 0
  }
];
export enum LanguageType {
  NL = "Natural Language",
  JavaScript = "JavaScript",
  Python = "Python",
  Matlab = "Matlab",
  Atk = "Atk",
  EWX = "EWX"
}

export const languageTypeToLabel = {
  [LanguageType.NL]: "自然语言",
  [LanguageType.JavaScript]: "JavaScript",
  [LanguageType.Python]: "Python",
  [LanguageType.Matlab]: "Matlab",
  [LanguageType.Atk]: "Atk",
  [LanguageType.EWX]: "未尔语言"
};
export type CodeLanguage = {
  label: string;
  value: string;
};
export const codeLanguages: CodeLanguage[] = [
  { label: languageTypeToLabel[LanguageType.NL], value: LanguageType.NL },
  { label: languageTypeToLabel[LanguageType.JavaScript], value: LanguageType.JavaScript },
  { label: languageTypeToLabel[LanguageType.Python], value: LanguageType.Python },
  { label: languageTypeToLabel[LanguageType.Matlab], value: LanguageType.Matlab },
  { label: languageTypeToLabel[LanguageType.Atk], value: LanguageType.Atk }
];
export const OpaqueLanguages: CodeLanguage[] = [
  { label: languageTypeToLabel[LanguageType.NL], value: LanguageType.NL },
  { label: languageTypeToLabel[LanguageType.JavaScript], value: LanguageType.JavaScript },
  { label: languageTypeToLabel[LanguageType.Python], value: LanguageType.Python },
  { label: languageTypeToLabel[LanguageType.Matlab], value: LanguageType.Matlab }
];
export type MatlabTypes = {
  label: string;
  value: string;
};
export const matlabTypes: MatlabTypes[] = [
  {
    label: "R2016b",
    value: "R2016b"
  },
  {
    label: "R2020b",
    value: "R2020b"
  }
];

if (customSystemConfig.EWX) {
  OpaqueLanguages.push({
    label: languageTypeToLabel[LanguageType.EWX],
    value: LanguageType.EWX
  });
}
/**
 * 打开编辑框操作
 */
export enum EditorOperateType {
  ADD = "add",
  OPEN = "open"
}

export const multiplicityItems: PropertyDropdownOption[] = [
  {
    label: "未指明",
    enLabel: "Unspecified",
    value: "Unspecified"
  },
  {
    label: "0",
    enLabel: "0",
    value: "0"
  },
  {
    label: "0..1",
    enLabel: "0..1",
    value: "0..1"
  },
  {
    label: "0..*",
    enLabel: "0..*",
    value: "0..*"
  },
  {
    label: "1",
    enLabel: "1",
    value: "1"
  },
  {
    label: "1..*",
    enLabel: "1..*",
    value: "1..*"
  },
  {
    label: "*",
    enLabel: "*",
    value: "*"
  }
];

export const reliabilitySelectOptions = [
  {
    key: "ReliabilityProfile::FMEA Profile::CauseOfFailure-occurrence",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      },
      {
        enLabel: "5",
        label: "5",
        value: "5"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::CauseOfFailure-premitigationOccurrences",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      },
      {
        enLabel: "5",
        label: "5",
        value: "5"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::FMEAItem-ESR",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::FMEAItem-DET",
    items: [
      {
        enLabel: "A",
        label: "A",
        value: "A"
      },
      {
        enLabel: "B",
        label: "B",
        value: "B"
      },
      {
        enLabel: "C",
        label: "C",
        value: "C"
      },
      {
        enLabel: "D",
        label: "D",
        value: "D"
      },
      {
        enLabel: "E",
        label: "E",
        value: "E"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::FMEAItem-OPR",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      },
      {
        enLabel: "5",
        label: "5",
        value: "5"
      },
      {
        enLabel: "6",
        label: "6",
        value: "6"
      },
      {
        enLabel: "7",
        label: "7",
        value: "7"
      },
      {
        enLabel: "8",
        label: "8",
        value: "8"
      },
      {
        enLabel: "9",
        label: "9",
        value: "9"
      },
      {
        enLabel: "10",
        label: "10",
        value: "10"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FTA Profile::Event-priority",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      },
      {
        enLabel: "5",
        label: "5",
        value: "5"
      },
      {
        enLabel: "6",
        label: "6",
        value: "6"
      },
      {
        enLabel: "7",
        label: "7",
        value: "7"
      },
      {
        enLabel: "8",
        label: "8",
        value: "8"
      },
      {
        enLabel: "9",
        label: "9",
        value: "9"
      },
      {
        enLabel: "10",
        label: "10",
        value: "10"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::FinalEffectOfFailure-Severity",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      }
    ]
  },
  {
    key: "ReliabilityProfile::FMEA Profile::FinalEffectOfFailure-premitigationSeverity",
    items: [
      {
        enLabel: "1",
        label: "1",
        value: "1"
      },
      {
        enLabel: "2",
        label: "2",
        value: "2"
      },
      {
        enLabel: "3",
        label: "3",
        value: "3"
      },
      {
        enLabel: "4",
        label: "4",
        value: "4"
      }
    ]
  }
];

export const reliabilitySelectOptionsMap = new Map<string, PropertyDropdownOption[]>();
reliabilitySelectOptions.forEach(it => {
  reliabilitySelectOptionsMap.set(it.key, it.items);
});
